﻿namespace WebAPI.Dao;

public class JsonConvert
{
    public static string ToJsonString(Dictionary<string, object> map)
    {
        string param = "{\r\n";
        int size = map.Count;
        
        foreach (var arg in map)
        {
            string key = Newtonsoft.Json.JsonConvert.SerializeObject(arg.Key);
            string value = Newtonsoft.Json.JsonConvert.SerializeObject(arg.Value);
            param += $"\t{key} : {value}";
            if (--size > 0)
            {
                param += ", \r\n";
            }
        }
        param += "\r\n}";

        return param;
    }
    
    public static string ToJsonString(string key, string value)
    {
        string param = "{\r\n";
        
        key = Newtonsoft.Json.JsonConvert.SerializeObject(key);
        value = Newtonsoft.Json.JsonConvert.SerializeObject(value);
        param += $"\t{key} : {value} \r\n";
        param += "}";

        return param;
    }
}